class Observe{
    constructor(data){
        this.data=data
        this.walk(data)
    }
    walk(data){
       if( !data || typeof data!=="Object"){
           return 
       }
       Object.keys(data).forEach(key=>{
            this.defineReactive(data,key,data[key])
       })
    }
    
    defineReactive(data,key,val){
        let that=this
        this.walk(val)
        Object.defineProperty(data,key,{
            enumerable:true,
            configurable:true,
            get(){
                
                return val
            },
            set(newValue){
                if(newValue===val){
                    return 
                }
                val=newValue
                that.walk(val)
            }
        })
    }
}